package nodes

import (
	"gitee.com/zfd81/dbrs/sql"
	"vitess.io/vitess/go/sqltypes"
)

// ShowTables is a node that shows the database tables.
type ShowTables struct {
	Full bool
}

var showTablesSchema = sql.Schema{
	{Name: "Table", Type: sqltypes.Text},
	{Name: "Comment", Type: sqltypes.Text},
	{Name: "Version", Type: sqltypes.Text},
}

var showTablesFullSchema = sql.Schema{
	{Name: "Table", Type: sqltypes.Text},
	{Name: "Table_type", Type: sqltypes.Text},
	{Name: "Comment", Type: sqltypes.Text},
	{Name: "Version", Type: sqltypes.Text},
}

func NewShowTables(full bool) *ShowTables {
	return &ShowTables{
		Full: full,
	}
}

// Resolved implements the Resolvable interface.
func (p *ShowTables) Resolved() bool {
	return false
}

// Schema implements the Node interface.
func (p *ShowTables) Schema() sql.Schema {
	if p.Full {
		return showTablesFullSchema
	}
	return showTablesSchema
}

func (p ShowTables) String() string {
	return "ShowTables"
}
